<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-type" content="text/html; charset=utf-8">
	<title>_Widget deferred connection test</title>
	<style type="text/css">
		@import "../themes/claro/document.css";
		@import "../themes/claro/claro.css";
		@import "css/dijitTests.css";
	</style>

	<script type="text/javascript" src="../../dojo/dojo.js"
		data-dojo-config="isDebug: true, parseOnLoad: true"></script>
	<script>
		dojo.require("dojo.parser");
		dojo.require("dijit.form.Button");

		overrodeMouseMoved = false;
		bothOverrodeMouseMoved = false;
		connectedMouseMoved = false;
		bothConnectedMouseMoved = false;

		function bothHandler(){
			if(!bothOverrodeMouseMoved){
				console.log("'both' button: overrode handler called");
			}
			bothOverrodeMouseMoved = true;
		}

		dojo.ready(function(){
			dojo.connect(dijit.byId("connect"), "onMouseMove", function(){
				if(!connectedMouseMoved){
					console.log("'connect' button: mouse moved");
				}
				connectedMouseMoved = true;
			});

			dojo.connect(dijit.byId("both"), "onMouseMove", function(){
				if(!bothConnectedMouseMoved){
					console.log("'both' button: connected handler");
				}
				bothConnectedMouseMoved = true;
			});
		});

	</script>
</head>
<body class="claro">
	<h1>Test deferred connections</h1>
	<p>
		OnMouseMove is a deferred connection, _Widget only call dojo.connect()
		(data-dojo-attach-event) to connect the onmousemove event on the focusNode to
		the widget method if needed.
	</p>
	<p>
		Mousing over the three buttons below should call the user-defined mouse-move
		handlers.  The "both" button has two handlers, and they should both be called.
	</p>

	<!--
		"overrode" button specifies an onmousemove handler on initialization.
	-->
	<button id="overrode" data-dojo-type="dijit/form/Button"
		data-dojo-props='onMouseMove:function(){ if(!overrodeMouseMoved){ console.log("\"overrode\" button: mouse moved"); } overrodeMouseMoved = true; }'>
		overrode
	</button>

	<!--
		"connect" button essentially is doing a dojo.connect("connect", "onMouseMove", myFunc).
		This should trigger an additional dojo.connect() call from Button.focusNode.onmousemove
		to the Button.onMouseMove empty function.
	-->
	<button id="connect" data-dojo-type="dijit/form/Button">
		connected
	</button>

	<button id="both" data-dojo-type="dijit/form/Button" data-dojo-props='onMouseMove:bothHandler'>
		both
	</button>
</body>
</html>
